refactor(web): normalize Ask user message text extraction#1371
Open
whoisthey wants to merge 2 commits into
Open
refactor(web): normalize Ask user message text extraction#1371whoisthey wants to merge 2 commits into
whoisthey wants to merge 2 commits into
Conversation
Introduce a shared `getUserMessageText` helper in the chat utils and use it everywhere the user's typed text is read from an `SBChatMessage`. Previously several call sites assumed the text lived at `parts[0]`, which silently drops the user's text if any non-text part (e.g. a file attachment) is ever first. The helper finds the first text part instead, making extraction robust to non-text parts. This is behavior-preserving today (user messages currently have a single leading text part) and is a prerequisite for chat file attachments. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
WalkthroughA shared helper now extracts user-message text from chat messages and replaces inline lookups in chat metadata, agent message history, chat naming, and thread previews. New tests cover text, non-text, and empty-part cases. ChangesShared chat user text extraction
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Minor item in preparation of file/multi-part input in 'Ask' mode
Summary
The Ask chat feature represents messages as Vercel AI SDK
UIMessages (SBChatMessage). Several call sites extracted the user's typed text with amessage.parts[0]assumption, which silently drops the text if any non-text part (e.g. a file attachment) is ever first.This PR introduces a shared
getUserMessageTexthelper inpackages/web/src/features/chat/utils.tsthat finds the first text part, and replaces the brittleparts[0]extraction at all call sites with it.This is behavior-preserving today (user messages currently have a single leading text part) and is a prerequisite for adding chat file attachments.
Summary by CodeRabbit